import request from '@/utils/request'
import type { Result, PageParams, PageResult } from '@/types/api'

// 租赁订单信息
export interface LeaseOrder {
  orderId: number
  code: string
  equipmentName: string
  userName: string
  contactPerson: string
  contactPhone: string
  startTime: string
  expectedReturnTime: string
  actualReturnTime?: string
  leaseDays: number
  chargeType: string
  leaseFee: number
  deposit: number
  depositStatus: number
  orderStatus: number
}

// 归还设备参数
export interface ReturnEquipmentParams {
  actualReturnTime: string
  isNormal: boolean
  remarks?: string
}

// 分页查询租赁订单
export function getLeaseOrderList(params: PageParams & {
  equipmentId?: number
  userId?: number
  status?: number
}) {
  return request.get<Result<PageResult<LeaseOrder>>>('/admin/leaseOrders', { params })
}

// 确认归还设备
export function confirmReturn(orderId: number, data: ReturnEquipmentParams) {
  return request.put<Result<LeaseOrder>>(`/admin/leaseOrders/${orderId}/return`, data)
} 